<%@page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!-- public quote -->
<%@include file="/jsp/comm_css_include.jsp"%>
<!-- jqgrid-->
<link href="${basePath}/css/plugins/jqgriddemo/css/ui.jqgrid-bootstrap.min.css" rel="stylesheet" />
<!doctype html>
<html>
<head>
	<style type="text/css">
		*{
			margin: 0px;
			padding: 0px;
			font-size: 12px;
		}
		.laydate-icon{
			height: 20px;
		}
	</style>
</head>
<body class="gray-bg">
	<div class="wrapper wrapper-content animated fadeInRight">
		 <div class="iboxtitle">
              <span><i class="glyphicon glyphicon-map-marker"></i>&nbsp;业务受理>基本资料登记</span>
         </div>
         <input type="hidden" id="id"/>
          <div class="ibox-content ibox-zxsearchqu ">
               <div class="row">
                   <div class="col-xs-12 col-sm-12 col-md-12 col-lg-4">
                  	 <div class="row">
                  	 	<div class="col-xs-6 col-sm-6 col-md-6 col-lg-6">  
	                   	   <label class="sr-only">客户名：</label>
	                       <input type="text" placeholder="客户名" id="customerName" name="customerName" class="form-control">
	                     </div>
	                     <div class="col-xs-6 col-sm-6 col-md-6 col-lg-6">    
	                       <label class="sr-only">业务员：</label>
	                       <input type="text" placeholder="业务员" id="salesmanName" name="salesmanName" class="form-control">
	                      </div> 
	                  </div>     
                   </div>
                   <div class="col-xs-12 col-sm-12 col-md-12 col-lg-4">
                   		<div class="row">
                   			<div class="col-xs-6 col-sm-6 col-md-6 col-lg-6">  
                   				<input id="beg_time" name="submitTimeStart" placeholder="开始时间" class="laydate-icon form-control">
                   			</div>
                   			<label class="hxleft">至</label>
	                        <div class="col-xs-6 col-sm-6 col-md-6 col-lg-6">  
	                        	<input id="end_time" name="submitTimeEnd" placeholder="结束时间" class="laydate-icon form-control">
	                        </div>
                        </div>
                    </div>
                    <div class="col-xs-12 col-sm-12 col-md-12 col-lg-4">
	                    <button class="btn dpbtn_blue_null" type="button" onclick="query(0,0);">当日</button>
						<button class="btn dpbtn_blue_null" type="button" onclick="query(-1,-1);">昨日</button>
						<button class="btn dpbtn_blue_null" type="button" onclick="query(-6,0);">近7日</button>
                   		<button class="zhixcx" type="button" onclick="query();">执行查询</button>
                    </div>
          	</div>
          </div>
          <%--  <div class="makesure-paidan">
		   		<button type="button" class="btn dpbtn_blue btnaplly" onclick="applayAllocation('${basePath}/YwBusinessController/applayAllocation');">申请派单</button>
		   </div> --%>
          <div class="ibox-content">	
          		<span class="warning-label"><span class="red-dp-circle"></span>初审单初审中（包括）之后，并且没有申请开卡的订单信息</span>	
	          	<div class="jqGrid_wrapper">
		             <table id="table_list_1"></table>
		             <div id="pager_list_1"></div>
	         	</div>
          </div>
	</div>
	<form class="form-horizontal business-form" id="commentForm">
		<div style="display: none;" id="applykaik">
	   	   <div class="business-padding">
	        	 <table cellpadding="0" cellspacing="0" border="0" class="buyinfor-table">
	        		 <tr>
	        		 	<td align="right">
							<label class="control-label np">申请日期：</label>
						</td>
						<td> 
							<input id="timeApplyOpencard" name="timeApplyOpencard" required="required" placeholder="申请日期(必填)" class="laydate-icon form-control" onclick="laydate();"/>
						</td>
					</tr>	
					 <tr>
	        		 	<td align="right" valign="top">
							<label class="control-label np">开卡备注：</label>
						</td>
						<td> 
							<textarea id="remarks" name="remarks" cols="8" required="required" placeholder="开卡备注(必填)" class="form-control" ></textarea>.
						</td>
					</tr>
				</table>	
	       </div>
	       <div class="padding-nono">
	        <table cellpadding="0" cellspacing="0" border="0" bordercolor="#3B95C8"  width="100%">
				<tr>
					<td width="100%" align="center">
						 <div class="ibox-content">
				              <button type="button" class="btn dpbtn_red " onclick="baocun();">确定</button>
				              <button id="" class="btn dpbtn_grey" type="button" onclick="canCel();">取消</button>
				          </div>
					</td>
				</tr>
			</table>
	   	 </div>
	   </div>
	 </form>  
	<!-- 申请派单 -->
   <%--  <%@include file="/jsp/comm_allocation_apply_include.jsp"%> --%>
    
	<!-- public quote -->
    <%@include file="/jsp/comm_js_include.jsp"%>

	<!-- jqGrid -->
    <script type="text/javascript" charset="utf-8" src="${basePath}/js/plugins/jqgriddemo/js/jquery.jqGrid.min.js"></script>
    <script type="text/javascript" charset="utf-8" src="${basePath}/js/plugins/jqgriddemo/js/grid.locale-cn.min.js"></script>	
    
    <!-- layerDate plugin javascript -->
    <script src="${basePath}/js/plugins/layer/laydate/laydate.js"></script>
    
    
    <!--
    	作者：zhangpp
    	时间：2017-04-06
    	描述：js
    -->
    <script type="text/javascript">
	    jQuery(function($) {  
	    	
	    	//外部js调用
		    laydate({
		        elem: '#beg_time', 
		        event: 'focus' 
		    });
	    	
		    laydate({
		        elem: '#end_time', 
		        event: 'focus' 
		    });
	    	
	    	getData();
	    });
	    
	    $(function(){
	        $("#commentForm").validate({
	            //重写showErrors
	            showErrors: function (errorMap, errorList) {
	                $.each(errorList, function (i, v) {
	                    layer.tips(v.message, v.element, { time: 1500 });
	                    return false;
	                });  
	            },
	            /* 失去焦点时验证 */
	            onfocusout: function(element) { $(element).valid(); },
	            /*  键盘抬起不验证 */
	            onkeyup:false,
	        });
		});
	    
	    var getData = function()
	    {
	    	var winWidth = $('div.ibox-content').width();
	    	var winHeight = document.body.offsetHeight - 330;
	     	var win = winWidth / 7 - 20;
  	 	   $.jgrid.defaults.styleUI = 'Bootstrap';
  	 	   
		  jQuery("#table_list_1").jqGrid
		  ({
			url:'${basePath}/OpenCardApplyController/multiList',
			postData:{},
	        datatype : "json",
	        colNames : [ '业务ID', '征信申请ID','申请开卡','业务提交时间', '客户姓名', '身份证号码', '经销商', '经销商等级', '订单类型','订单类型', '部门','业务员', '银行','客户Id'],
	        colModel : [ 
	                     {name: 'replaceId', index: 'id', hidden:true},
	                     {name: 'queryCreditApplyId', index: 'queryCreditApplyId', hidden:true},
	                     {name: 'operate', index: 'operate',fixed: 'right',width: 120,
	            			 formatter: function (value, grid, rows, state) { 
	            				 return '<button class="btn dpbtn_small_red" onclick="openCardApply(\''+ rows.replaceId + '\');">申请开卡</button>';
	            			} 	 
	            		 },
	                     {name: 'submitTime',index: 'submitTime',width: 180,align: "center",formatter:function(a,b,c){
	                       	 return formateToMinutes(a);
	                     }},
	            		 {name: 'customerName',index: 'customerName',width: 130,align: "center"},
	            		 {name: 'customerNo',index: 'customerNo',width: 170,align: "center"},
	               		 {name: 'dealerName',index: 'dealerName',width: 300,align: "center"},
	               		 {name: 'dealerLevelDisplay',index: 'dealerLevel',width: 130,align: "center"},
	               		 {name: 'channelTypeDisplay',index: 'B.channelType',width: 130,align: "center",formatter:function(a,b,c){
	    					return '<span class="channelType">' + a + '</span>';
	    	              }},
	    	             {name: 'channelType',index: 'B.channelType', hidden:true},
	            		 {name: 'orgName',index: 'orgName',width: 130,align: "center"},
	            		 {name: 'salesmanName',index: 'salesmanName',width: 130,align: "center"},
	            		 {name: 'bankLoanDisplay',index: 'bankLoan',width: 300,align: "center"},
	            		 {name: 'customerId', index: 'customerId', hidden:true}
	                   ],
              mtype : "post",
              height: winHeight,
              width:winWidth,  
              shrinkToFit:false,
              autoScroll: false,
              rowNum: 15,
              rowList: [15, 30, 45],
              viewrecords: true,
              pager: "#pager_list_1",
              hidegrid: false,
              multiselect : false,
              altRows:true,
              altclass:'someClass',
              ondblClickRow:function(rowId,v,e)
              {
             	  var rowData = $("#table_list_1").jqGrid("getRowData", rowId);
             	  var id = rowData.replaceId;
             	  var queryCreditApplyId = rowData.queryCreditApplyId;
             	  window.location.href="${basePath}/OpenCardApplyViewController/teoperCardApply?busiId="+id+"&queryCreditApplyId="+queryCreditApplyId;
               },
              jsonReader : {
            	  root:"result.rows",
            	  page: "result.page",
            	  total: "result.total",
            	  records: "result.records",
            	  repeatitems: false,
            	  id: "replaceId"
              },
              loadComplete:function(datas){
            	  if (datas.flag == "100100") {
                      layer.msg("查询成功!", {icon: 6, time: 1000});
                      return;
                  }
            	  if (datas.flag == "100200") {
                      $.fn.showDatas({"datas": datas});
                      return;
                  }
                  layer.msg(datas.message, {icon: 2});
              }
	      });
	    }
	    
	    var openIndex;
	    
	    function canCel(){
	    	layer.close(openIndex);
	    }
	    
	    function openCardApply(id){ 
	    	var data={};
	    	$("#id").val(id);
	    	data.dataid=id;
	    	openIndex = layer.open({
     		    title:"申请开卡",
	        	    type: 1,
	        	    area: ['400px', '350px'], //宽高
	        	    content: $('#applykaik')
       	     });
       }  
	    
	   function baocun(){
		   var validstatus = $("#commentForm").valid();
    	   if(validstatus)
    	   {
    		   submitOpenCardApply($("#id").val());
    	   }
	   } 
	    
	    var submitOpenCardApply=function(id){
	    	var data={};
	    	data.id=id;
	    	data.timeApplyOpencard=$("#timeApplyOpencard").val();
	    	data.remark=$("#remarks").val();
	    	layer.confirm('确认申请开卡？操作人：<span style="color:#BD1723;">${current_user_key.uname}</span>', {
	    		  btn: ['确定','取消'],//按钮
	    		  title:"变更主借人" 
	    		}, function(){
	    			layer.closeAll();
			    	$.dpAjax({
			    		url:'${basePath}/OpenCardApplyController/modify',
			    		data:data,
		    			success: function(datas){
			    			  if(datas.flag == "100100")
							  {
								$("#timeApplyOpencard").val("");
								$("#remarks").val("");
								layer.close(openIndex);
								refresh();
								return;
							  }
							  if(datas.flag == "100200")
			                  {
								  $.fn.showDatas({"datas":datas});
			                	  return;
			                  }
		                 }
			    	});
	    		})	
	    }
	    var query = function(start, end){
	    	var postData = $("#table_list_1").jqGrid("getGridParam", "postData");
	    	var data = {};
	    	data.customerName = document.getElementById('customerName').value || '';
	    	data.salesmanName = document.getElementById('salesmanName').value || '';
	    	if(start != null && typeof start != 'undefined') {
	    		document.getElementById('beg_time').value = laydate.now(start);
	    		document.getElementById('end_time').value = laydate.now(end);
	    	}
	    	data.submitTimeStart = document.getElementById('beg_time').value.trim();
	    	data.submitTimeEnd = document.getElementById('end_time').value.trim();
	    	
	    	$.extend(postData, data);
	    	refresh();
	    }
	    
	    var refresh = function()
	    {
	    	$("#table_list_1").jqGrid("setGridParam", { search: true }).trigger("reloadGrid", [{ page: 1}]);
	    }
    </script>
</body>
</html>
